package Day2025_02_24;

public class LeetCode724 {
    public int pivotIndex(int[] nums) {
        int n = nums.length;
        int sum = 0;
        for (int i : nums) sum += i;
        int tmp = 0;
        for (int i = 0; i < n; i++) {
            tmp += nums[i];
            if (sum - tmp == tmp - nums[i]) return i;
        }
        return -1;
    }
}
